package com.wiiss.common.enums;

import com.wiiss.common.utils.StringUtils;
import org.springframework.util.CollectionUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 过滤请求和返回报文不打印
 */
public enum ControllerFilterLogInfo {
    REQ_001("REQ", "upload", "流程定义"),
    REQ_002("REQ", "export", "导出model的xml文件"),

    RSP_001("RESP", "getStencilset", "")


    ;
    private final String type;
    private final String url;
    private final String info;

    ControllerFilterLogInfo(String type, String url, String info) {
        this.type = type;
        this.url = url;
        this.info = info;
    }
    public String getType() {
        return type;
    }

    public String getUrl() {
        return url;
    }

    public String getInfo() {
        return info;
    }

    public static boolean filterMethod(String type, String url) {
        List<ControllerFilterLogInfo> collect = Arrays.stream(values())
                .filter(it -> StringUtils.equals(it.getType(), type)
                        && StringUtils.contains(url, it.getUrl()))
                .collect(Collectors.toList());
        return !CollectionUtils.isEmpty(collect);
    }
}
